package ahu.zdw.com;

import java.util.Stack;

/**
 * Author: Zhang Dongwei
 * Date: 2021/12/19 11:03
 */
public class Test2 {
    public static void main(String[] args) {
        String s = "[]{()[]}";
        Stack<Character> stack = new Stack<Character>();

//        System.out.println(stack);
//        stack.push(')');
//        System.out.println(stack);
//        stack.push(']');
//        System.out.println(stack);
//        stack.push('}');
//        System.out.println(stack);
//        stack.push('[');
//        System.out.println(stack);
//        System.out.println(stack.pop());

        int n = s.length();
        for(int i = 0;i<n;i++){
            char a = s.charAt(i);

            if(a=='(')
                stack.push(')');
            else if(a=='{')
                stack.push('}');
            else if(a=='[')
                stack.push(']');
            else{
                if(stack.isEmpty()||stack.pop()!=a ){
                    System.out.println("false");
                }
            }
            System.out.println(stack);
        }

        System.out.println("Hello Leetcode in Gitee!");
        System.out.println("This is a test in a different computer!");
    }
}
